﻿#ifndef _CAN_INTERFACE_H_
#define _CAN_INTERFACE_H_

#include <iostream>
#include <memory>
#include <atomic>
#include <thread>
#include <string>
#include <chrono>
#include <stdexcept>
#include <stdbool.h>
#include "inicpp.h"
#include "fifo.h"
#include "ControlCan.h"

class CAN
{
public:
    typedef std::shared_ptr<CAN> Ptr;
    CAN();
    ~CAN();
    void RxTxThreadStart();
    void RxTxThreadStop();
    int Transmit(LCAN_CAN_OBJ *data, int count);
    int Receive(LCAN_CAN_OBJ *data, int count);

private:
    int m_deviceType;
    int m_deviceIndex;
    int m_canIndex;
    std::atomic<bool> m_RxTxThreadRunning;
    std::thread m_RxTxThread;
    FIFO<LCAN_CAN_OBJ> m_RxFifo;
    FIFO<LCAN_CAN_OBJ> m_TxFifo;
};

#endif /*_CAN_INTERFACE_H_*/